package com.okami.study.threetensix;

import java.util.EnumSet;
import java.util.List;
import java.util.Objects;
import java.util.Set;

/**
 * @author: TanJingyu
 * @create: 2021-03-16 15:50
 **/
abstract class Pizza {
    enum Topping {
        HAM,MUSHROOM,ONION,PEPPER,SAUSAGE
    }
    private final Set<Topping> toppings;

    Pizza(Builder builder) {
        toppings = builder.toppings.clone();
    }

    abstract static class Builder<T extends Builder<T>> {
        EnumSet<Topping> toppings = EnumSet.noneOf(Topping.class);

        T addTopping(Topping topping) {
            toppings.add(Objects.requireNonNull(topping));
            return self();
        }

        protected abstract T self();

        abstract Pizza build();
    }
}
